Re: design/copying a bunch of records

Поиск
Список
Период
Сортировка
От M Spreij
Тема Re: design/copying a bunch of records
Дата
Msg-id a05210602bb45f12e6c1f@[192.168.1.12]
обсуждение исходный текст
Ответ на Re: design/copying a bunch of records  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-novice
>  >    So I figured the best way was to copy the records from the
>>  admin-set to user-sets (but suggestions for other ways are very
>>  welcome!), and was wondering if there is a 'good' way to copy about
>>  50 records to different tables every time you add a user account -
>>  the only way I can think of is write some loops in PHP. Better ways?
>>  TIA!
>
>Yes ... the better way is to just have all products in one big table with a
>column to indicate what user they belong to.   And then to modify the PHP
>query for each user so that it always includes both his and the admin's
>products.  The same approach should be used with other "user specific"
>tables.

I forgot to mention there were a few differences needed between the
admin and user sets, so I already had gone with the two tables.
Now I'm trying to get this nifty postgresql code to work for me.. can
anyone point out what I'm doing wrong? Trying to copy the records
from the first groups into cgroups:
-------------------------
$sql = "
DECLARE
tRecord RECORD;
BEGIN
FOR tRecord IN (SELECT id, kind, name, col_1, col_2, col_3, display
FROM groups) LOOP
    INSERT INTO cgroups (id, kind, name, col_1, col_2, col_3,
display, user_id)
        VALUES (tRecord.id, tRecord.kind, tRecord.name,
tRecord.col_1, tRecord.col_2, tRecord.col_3, tRecord.display,
$user_id);
END LOOP;
END;
";

pg_query($sql);
-------------------------
-> PostgreSQL query failed:  ERROR:  parser: parse error at or near "record"

PHP 4.1.2, PostgreSQL 7.1

TIA!

Regards,

     Martin
--
<mailto:mac.com@nemo>
<http://www.mechintosh.com/>

В списке pgsql-novice по дате отправления:

Предыдущее
От: M Spreij
Дата:
Сообщение: Re: Questions about Exists-Not exists clause
Следующее
От: Avi Schwartz
Дата:
Сообщение: Re: Questions about Exists-Not exists clause